import { request } from './request'
import { IMenu } from './menu'

const api = {
  detail: '/customer/detailCustomerTypeMenu', // 租户类型详情
  list: '/customer/listCustomerTypeMenu', // 租户类型列表
  upsert: '/customer/upsertCustomerTypeMenu', // 更新租户类型菜单
  delete: '/customer/deleteCustomerTypeMenu', // 删除租户类型
}

/**
 * 租户详情
 */
export const getCustomerTypeDetail = (id: string) => {
  return request.get(`${api.detail}/${id}`)
}

/**
 * 租户类型列表
 */
export const getCustomerTypeList = () => {
  return request.get(api.list)
}

export type IUpsertParams = {
  customerName: string
  customerType: number
  id: number
  menuList: IMenu[]
}

/**
 * 更新租户类型菜单
 */
export const upsertCustomerTypeMenu = (params: IUpsertParams) => {
  return request.put(api.upsert, params)
}

export const deleteCustomerType = (id: string) => {
  return request.delete(`${api.delete}/${id}`)
}
